package com.vnp.vchat.util;

import java.util.Calendar;

import com.telpoo.frame.utils.Mlog;

import android.content.Context;
import android.content.SharedPreferences;

public class PreferenceHelper {
	private SharedPreferences sharedPreferences;
	public static final String PREFERENCE_FILE = "preference_file.com.vnp.vChat";
	
	// user_id
	public static final String USER_ID = "user_id";
	public static final String USER_NAME = "user_name";
	public static final String VCHAT_DEVIDE_ID = "device_id";
	
	// hash
	public static final String HASH = "hash";
	public static final String HASH_SETTING = "hash_settings";
	
	// settings
	public static final String SETTING_NOTIFI = "setting_notifi";
	public static final String SETTING_FEED = "setting_feed";
	public static final String SETTING_DISPLAY = "setting_display";
	
	// connect
	public static final String DOMAIN_CONNECT = "domain_connect";
	public static final String POST_CONNECT = "post_connect";
	public static final String DATA_JOIN = "data_join";
	
	public static final String AVATAR_KH = "avatar_kh";
	public static final String MY_AVATAR = "my_avatar";
	
	public static final String MY_VGC = "my_vgc";
	
	public static final String EMAIL = "email";
	public static final String PHONE = "so_dt";
	public static final String ADMIN_ID = "admin_id";
	
	public static final String TIME_GET_CONTACT = "time_get";
	
	public static final String SETTING_RINGTONE = "ringtone";
	
	
	public PreferenceHelper(Context context) {
		this.sharedPreferences = context.getSharedPreferences("vChat", 0);
	}
	
	
	//------------------------------------------------//
	
	
	public int getSettingRingtone(){
		return this.sharedPreferences.getInt(SETTING_RINGTONE, 1);
	}
	
	public long getTimeGetContact(){
		return this.sharedPreferences.getLong(TIME_GET_CONTACT, 0);
	}
	
	public String getAdminId(){
		return this.sharedPreferences.getString(ADMIN_ID, "");
	}
	
	public String getEmail(){
		return this.sharedPreferences.getString(EMAIL, "");
	}
	
	public String getPhone(){
		return this.sharedPreferences.getString(PHONE, "");
	}
	
	public String getHashSetting(){
		return this.sharedPreferences.getString(HASH_SETTING, "");
	}
	
	public String getMyAvatar(){
		return this.sharedPreferences.getString(MY_AVATAR, "");
	}
	
	public String getDeviceId(){
		return this.sharedPreferences.getString(VCHAT_DEVIDE_ID, "");
	}
	
	public String getUserName(){
		return this.sharedPreferences.getString(USER_NAME, "");
	}
	
	public String getAvatarKH(){
		return this.sharedPreferences.getString(AVATAR_KH, "");
	}
	
	public String getDataJoin(){
		return this.sharedPreferences.getString(DATA_JOIN, "");
	}
	
	public String getPostConnect(){
		return this.sharedPreferences.getString(POST_CONNECT, "");
	}
	
	public String getDomainConnect(){
		return this.sharedPreferences.getString(DOMAIN_CONNECT, "");
	}
	
	
	public String getHash(){
		return this.sharedPreferences.getString(HASH, "");
	}
	
	public String getUserId(){
		return this.sharedPreferences.getString(USER_ID, "");
	}
	
	public String getSettingDisplay(){
		return this.sharedPreferences.getString(SETTING_DISPLAY, "");
	}
	
	public String getSettingNotifi(){
		return this.sharedPreferences.getString(SETTING_NOTIFI, "");
	}
	
	public String getSettingFeed(){
		return this.sharedPreferences.getString(SETTING_FEED, "");
	}
	
	public long getVgc(){
		return this.sharedPreferences.getLong(MY_VGC, -1);
	}
	
	
	
	//------------------------------------------------//
	public void setHashSetting(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(HASH_SETTING, value);
		localEditor.commit();
	}
	
	
	public void setVgc(long value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putLong("MY_VGC", value);
		localEditor.commit();
	}
	
	
	
	
	public void setSettingDisplay(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(SETTING_DISPLAY, value);
		localEditor.commit();
	}
	
	
	public void setSettingNotifi(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(SETTING_NOTIFI, value);
		localEditor.commit();
	}
	
	public void setSettingFeed(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(SETTING_FEED, value);
		localEditor.commit();
	}
	
	public void setHash(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(HASH, value);
		localEditor.commit();
	}
	
	public void setUserId(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(USER_ID, value);
		localEditor.commit();
	}
	
	public void setDomainConnect(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(DOMAIN_CONNECT, value);
		localEditor.commit();
	}
	
	public void setPostConnect(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(POST_CONNECT, value);
		localEditor.commit();
	}
	
	public void setDataJoin(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(DATA_JOIN, value);
		localEditor.commit();
	}
	
	public void setAvatarKH(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(AVATAR_KH, value);
		localEditor.commit();
	}
	
	public void setUserName(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(USER_NAME, value);
		localEditor.commit();
	}
	
	public void setDeviceId(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(VCHAT_DEVIDE_ID, value);
		localEditor.commit();
	}
	
	public void setMyAvatar(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(MY_AVATAR, value);
		localEditor.commit();
	}
	
	public void setEmail(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(EMAIL, value);
		localEditor.commit();
	}
	
	public void setPhone(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(PHONE, value);
		localEditor.commit();
	}
	
	public void setAdminId(String value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putString(ADMIN_ID, value);
		localEditor.commit();
	}
	
	public void setTimeGetContact(long value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putLong(TIME_GET_CONTACT, value);
		localEditor.commit();
	}
	
	public void setSettingsRingtone(int value){
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putInt(SETTING_RINGTONE, value);
		localEditor.commit();
	}
	
	public void clear() {
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.clear();
		localEditor.commit();
	}


	public String getLink() {
		return "android_app";
	}


	public void setTimeGetHistory() {
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putLong("setTimeGetHistory", Calendar.getInstance().getTimeInMillis());
		localEditor.commit();
		
	}
	
	public long getTimeGetHistory(){
		return this.sharedPreferences.getLong("setTimeGetHistory", Long.MAX_VALUE);
	}


	public void setTimeSocketConnected() {
	
		SharedPreferences.Editor localEditor = this.sharedPreferences.edit();
		localEditor.putLong("setTimeSocketConnected", Calendar.getInstance().getTimeInMillis());
		localEditor.commit();
	}
	
	public long getTimeSocketConnected(){
		return this.sharedPreferences.getLong("setTimeSocketConnected", Long.MAX_VALUE);
	}
	
	
}
